import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';

// for config.{env}.ts
export type DefaultConfig = PowerPartial<EggAppConfig & BizConfig>;

// app special config scheme
export interface BizConfig {
  sourceUrl: string;
}

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig> & BizConfig;

  // app special config
  config.sourceUrl = `https://github.com/eggjs/examples/tree/master/${appInfo.name}`;

  // override config from framework / plugin
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1531127600284_9912';

  // add your config here
  config.middleware = [];

  config.mongoose = {
    url: 'mongodb://127.0.0.1:12345/young_card',
    // option: {}
  };

  config.session = {
    key: 'swaggy',
    maxAge: 24 * 3600 * 1000,
    httpOnly: true,
    encrypt: true,
  };
  config.security = {
    csrf: {
      enable: false,
    }
  };
  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      host: '60.205.208.93',
      // 端口号
      port: '3306',
      // 用户名
      user: 'root',
      // 密码
      password: 'Xmj5_=tNa!J!',
      // 数据库名
      database: 'class',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };
  config.bodyParser = {
    jsonLimit: '1000mb',
    formLimit: '1000mb',
  };
  config.multipart = {
    fileSize : "10000mb"
  }
  return config;
};
